<p>This rule raises an issue when <code>.indexOf()</code> or <code>.lastIndexOf()</code> are used with comparison operators to check element
existence, or when <code>Array#some()</code> is used for simple equality checks that could be replaced with <code>.includes()</code>.</p>
<h2>Why is this an issue?</h2>
<p>Using <code>.indexOf()</code> or <code>.lastIndexOf()</code> with comparison operators like <code>!== -1</code> or <code>&gt;= 0</code> to check if
an element exists is less readable and semantic than using <code>.includes()</code>. The intent is not immediately clear - you need to understand that
<code>-1</code> means "not found" and remember the comparison logic.</p>
<p>The <code>.includes()</code> method was specifically designed for existence checks. It clearly expresses the intent: "does this array/string
include this element?" This makes code more readable and self-documenting.</p>
<p>Similarly, using <code>Array#some()</code> for simple equality checks is overkill. The <code>some()</code> method is designed for complex
conditions and predicates. When you only need to check if an element exists, <code>.includes()</code> is more appropriate and can be more performant
since it doesn’t need to execute a callback function.</p>
<p>Using the right method for the right purpose makes code more maintainable and easier to understand for other developers.</p>
<h3>What is the potential impact?</h3>
<p>This issue affects code readability and maintainability. While it doesn’t cause runtime errors, it makes code harder to understand and review.
Using inappropriate methods can also have minor performance implications, as <code>.indexOf()</code> returns an index that gets discarded, and
<code>Array#some()</code> executes callback functions unnecessarily.</p>
<h3>How to fix?</h3>
<p>Replace <code>.indexOf()</code> comparisons with <code>.includes()</code>. Instead of checking if the index is not -1 or greater than -1, directly
use <code>.includes()</code> to check existence.</p>
<h4>Non-compliant code example</h4>
<pre data-diff-id="1" data-diff-type="noncompliant">
if (array.indexOf('foo') !== -1) { // Noncompliant
  // element found
}

if (string.lastIndexOf('bar') &gt;= 0) { // Noncompliant
  // element found
}
</pre>
<h4>Compliant code example</h4>
<pre data-diff-id="1" data-diff-type="compliant">
if (array.includes('foo')) {
  // element found
}

if (string.includes('bar')) {
  // element found
}
</pre>
<h3>Documentation</h3>
<ul>
  <li> <a href="https://github.com/sindresorhus/eslint-plugin-unicorn#readme">eslint-plugin-unicorn</a> - Rule <a
  href="https://github.com/sindresorhus/eslint-plugin-unicorn/blob/HEAD/docs/rules/prefer-includes.md">prefer-includes</a> </li>
  <li> MDN - Array.prototype.includes() - <a
  href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes">Official documentation for the Array
  includes() method</a> </li>
  <li> MDN - String.prototype.includes() - <a
  href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes">Official documentation for the String
  includes() method</a> </li>
  <li> MDN - Array.prototype.some() - <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some">Official
  documentation for the Array some() method</a> </li>
</ul>
